﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using System.Data;

namespace PTTPOS_Solution.DAL
{
    public static class Orderdetail2s_DA
    {
        /// <summary>
        /// Phương thức cho nút xác nhận tách bàn
        /// </summary>
        public static void AppendOrderdetail2s(string id_order, List<string> lstproductname)
        {
            foreach (string strProductname in lstproductname)
            {
                MySqlCommand com = new MySqlCommand("insert into tblorderdetail2s(id_order, Productname, Price, Amount) select (select max(id) from tblorders), Productname, Price, Amount from tblorderdetail2s_pro where id_order = @id_order and productname=@productname", Connection_PTTPOS.GetConnection());
                com.Parameters.AddWithValue("@id_order", id_order);
                com.Parameters.AddWithValue("@productname", strProductname.Split('|')[0]);
                com.Connection.Open();
                com.ExecuteNonQuery();
                com.Connection.Close();
            }
        }
        public static void AppendOrderdetail2s(string id_order)
        {
                MySqlCommand com = new MySqlCommand("insert into tblorderdetail2s(id_order, Productname, Price, Amount) select (select max(id) from tblorders), Productname, Price, Amount from tblorderdetail2s_pro where id_order = @id_order", Connection_PTTPOS.GetConnection());
                com.Parameters.AddWithValue("@id_order", id_order);
                com.Connection.Open();
                com.ExecuteNonQuery();
                com.Connection.Close();
        }
        
    }
}
